<?php

$links_file = "{$_SERVER["DOCUMENT_ROOT"]}/modules/footer/links.json";

if (! function_exists('objectToArray'))  {
	function objectToArray($d) {
		if (is_object($d)) {
			// Gets the properties of the given object
			// with get_object_vars function
			$d = get_object_vars($d);
		}
 
		if (is_array($d)) {
			/*
			* Return array converted to object
			* Using __FUNCTION__ (Magic constant)
			* for recursive call
			*/
			return array_map(__FUNCTION__, $d);
		}
		else {
			// Return array
			return $d;
		}
	}
}

if (isset($_REQUEST["save"])) {
    $links = array (
    "about" => array (
        "text" => "About this site",
        "links" => array (
            "0" => array ("url" => "about_us.html", "text" => "About us"),
            "1" => array ("url" => "Accessibility_help.html","text" => "Accessibility help"),
            "2" => array ("url" => "sitemap.html","text" => "Site map"),
            "3" => array ("url" => "terms_and_conditions.html","text" => "Terms & conditions"),
            "4" => array ("url" => "privacy_policy.html","text" => "Privacy policy"),
            "5" => array ("url" => "information_for_staff.html","text" => "Information for college staff") 
        )
    ),
    "browse" => array (
        "text" => "Browse site",
        "links" => array (
            "0" => array ("url" => "applying_to_prc.html", "text" => "Applying to PRC"),
            "1" => array ("url" => "why_peterborough.html","text" => "Why Peterborough?"),
            "2" => array ("url" => "latest_news.html","text" => "Latest news"),
            "3" => array ("url" => "events.html","text" => "Events"),
            "4" => array ("url" => "facilities.html","text" => "Facilities"),
            "5" => array ("url" => "visit_peterborough.html","text" => "Visit Peterborough") 
        )
    ),
    "quicklinks" => array (
        "text" => "Quicklinks",
        "links" => array (
            "0" => array ("url" => "contact_us.html", "text" => "Contact us"),
            "1" => array ("url" => "find_a_course.html","text" => "Find a course"),
            "2" => array ("url" => "student_support.html","text" => "Student support"),
            "3" => array ("url" => "find_a_scholarship.html","text" => "Find a scholarship"),
            "4" => array ("url" => "find_us_on_facebook.html","text" => "Find us on Facebook"),
            "5" => array ("url" => "follow_us_on_twitter.html","text" => "Follow us on Twitter") 
        )
    ),
    "courses" => array (
        "text" => "Courses",
        "links" => array (
            "0" => array ("url" => "school_leavers.html", "text" => "School leavers"),
            "1" => array ("url" => "degree_courses.html","text" => "Degree courses"),
            "2" => array ("url" => "international_courses.html","text" => "International courses"),
            "3" => array ("url" => "business_and_employers","text" => "Business & employers"),
            "4" => array ("url" => "adult_learning.html","text" => "Adult learning"),
            "5" => array ("url" => "apprenticeships.html","text" => "Apprenticeships") 
        )
    )
    );

    $accreditations = array (
    "0" => array ("text" => "ncfe Investing in Quality", "url" => "accreditation/ncfe.html", "img" => "/images/footer_logos/ncfe_logo.gif"),
    "1" => array ("text" => "MINDFUL EMPLOYER", "url" => "accreditation/mindful.html", "img" => "/images/footer_logos/mindful_logo.gif"),
    "2" => array ("text" => "Positive About Disabled People", "url" => "accreditation/positive.html", "img" => "/images/footer_logos/positive_logo.gif"),
    "3" => array ("text" => "matrix", "url" => "accreditation/matrix.html", "img" => "/images/footer_logos/matrix_logo.gif"),
    "4" => array ("text" => "disabledGo", "url" => "accreditation/dgo.html", "img" => "/images/footer_logos/dgo_logo.gif"),
    "5" => array ("text" => "next step ", "url" => "accreditation/next_text.html", "img" => "/images/footer_logos/ncfe_logo.gif"),
    "6" => array ("text" => "INVESTORS IN PEOPLE", "url" => "accreditation/investors.html", "img" => "/images/footer_logos/investors_logo.gif"),
    "7" => array ("text" => "European Union European Social Fund", "url" => "accreditation/europe.html", "img" => "/images/footer_logos/europe_logo.gif")
    );

    $fp = fopen($links_file, 'w');
    fwrite($fp, json_encode($links));
    fclose($fp);
}

$links = objectToArray(json_decode(file_get_contents($links_file)));

$copyright = "Copyright &copy; {$config["copyright"]}. All rights reserved. <b>General Enquiries:  {$config["telephone"]}</b>";
$site_by = "site by <a href=http://dsq.co.uk>dsquared</a>";

?>
